﻿using System.IO;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mvc.RazorTools.FontAwesome.Tests
{
	[TestClass]
	public class FontAwesomeStackHtmlTests
	{
		[TestMethod]
		[TestCategory("FontAwesomeStackHtmlTests")]
		public void FontAwesomeStackHtmlConstructorTest1()
		{
			using (MemoryStream io = new MemoryStream())
			{
				using (TextWriter writer = new StreamWriter(io))
				{
					ViewContext vc = new ViewContext();
					vc.Writer = writer;
					ViewData data = new ViewData();
					HtmlHelper html = new HtmlHelper(vc, data);

					FontAwesomeStackHtml stackHtml = new FontAwesomeStackHtml(html);

					writer.Flush();
					string[] htmlText = writer.Encoding.GetString(io.GetBuffer()).Split(new char[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries);

					Assert.AreEqual(string.Format("<span class=\"{0}\">", FontAwesomeStyles.Stack), htmlText[0]);
				}
			}
		}

		[TestMethod]
		[TestCategory("FontAwesomeStackHtmlTests")]
		public void FontAwesomeStackHtmlConstructorTest2()
		{
			using (MemoryStream io = new MemoryStream())
			{
				using (TextWriter writer = new StreamWriter(io))
				{
					ViewContext vc = new ViewContext();
					vc.Writer = writer;
					ViewData data = new ViewData();
					HtmlHelper html = new HtmlHelper(vc, data);

					FontAwesomeStackHtml stackHtml = new FontAwesomeStackHtml(html, FontAwesomeStyles.Large1x);

					writer.Flush();
					string[] htmlText = writer.Encoding.GetString(io.GetBuffer()).Split(new char[] { '\r', '\n' }, System.StringSplitOptions.RemoveEmptyEntries);

					Assert.AreEqual(string.Format("<span class=\"{0} {1}\">", FontAwesomeStyles.Stack, FontAwesomeStyles.Large1x), htmlText[0]);
				}
			}
		}
	}
}
